package cn.vihub.controller;

import cn.vihub.param.ShopGoodsParam;
import cn.vihub.pojo.ShopGoods;
import cn.vihub.service.ShopGoodsService;
import cn.vihub.utils.Result;
import cn.vihub.vo.ShopGoodsVo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: 秋晚
 * @Date: 2025/7/29 20:15
 * @Description:
 **/
@RestController
@RequestMapping("shop-store/goods")
public class ShopGoodsController {


    @Autowired
    ShopGoodsService shopGoodsService;

    @GetMapping("goodsPage")
    public Result<IPage<ShopGoodsVo>> goodsPage(ShopGoodsParam shopGoodsParam){
        return Result.success(shopGoodsService.goodsPage(shopGoodsParam));
    }


    @GetMapping("getGoodsInfo/{id}")
    public Result<ShopGoodsVo> getGoodsInfo(@PathVariable(name = "id") Integer id){
        return Result.success(shopGoodsService.getGoodsInfo(id));
    }

    /**
     * @author: 秋晚
     * @description:新增商品数据
     * @params: [cn.vihub.param.ShopGoodsParam]
     * @return: cn.vihub.utils.Result<java.lang.Boolean>
     * @date: 2025/8/1 11:51
     */
    @PostMapping("add")
    public Result<Boolean> add(@RequestBody ShopGoodsParam shopGoodsParam){
        return Result.success(shopGoodsService.add(shopGoodsParam));
    }


}
